@extends('admin.layout.base')

@section('main')
    <h1 class="page-header">编辑游戏</h1>
    @if (count($errors) > 0)
        <div class="alert alert-danger">
            <strong>糟糕!</strong> 发生以下错误<br><br>
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif
    <form action="{{ route('admin.games.update', $game->id) }}" method="post">
        <div class="col-md-9">

            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <input type="hidden" name="_method" value="PATCH">

            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label>名称</label>
                        <input type="text" class="form-control" name="name" placeholder="三国名将"
                               value="{{ $game->name }}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label>包名</label>
                        <input type="text" class="form-control" name="package_name" placeholder="com.xxoo"
                               value="{{ $game->package_name }}">
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label>大小</label>
                        <input type="text" class="form-control" name="size" placeholder="12M"
                               value="{{ $game->size }}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label>分类</label>
                        <select class="form-control" name="category_slug">
                            <option value="{{ $game->category_slug }}">{{ $game->category_slug }}</option>
                            @foreach(\App\Models\Category::all() as $cat)
                                <option value="{{ $cat->slug }}">{{ $cat->name }}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label>图标地址</label>
                <input type="url" class="form-control" name="icon" placeholder="图标地址"
                       value="{{ $game->icon }}">
            </div>
            <div class="form-group">
                <label>海报地址</label>
                <input type="url" class="form-control" name="poster" placeholder="海报地址"
                       value="{{ $game->poster }}">
            </div>
            <div class="form-group">
                <label>下载地址</label>
                <input type="url" class="form-control" name="download_url" placeholder="下载地址"
                       value="{{ $game->getOriginal('download_url') }}">
            </div>
            <div class="form-group">
                <label>微下载地址</label>
                <input type="url" class="form-control" name="wx_download_url" placeholder="微下载地址"
                       value="{{ $game->wx_download_url }}">
            </div>
            <div class="form-group">
                <label>简介</label>
                <input type="text" class="form-control" name="brief_desc" placeholder="一句话简介"
                       value="{{ $game->brief_desc }}">
            </div>
            <div class="form-group">
                <label>详情介绍</label>
                    <textarea class="form-control" placeholder="详细介绍" name="description"
                              rows="10">{{ $game->description }}</textarea>
            </div>
        </div>
        <div class="col-md-3">
            <div class="panel panel-default">
                <div class="panel-heading">保存</div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="checkbox checkbox-success">
                            <input id="top" type="checkbox" name="top" value="1" @if($game->top) checked @endif >
                            <label for="top">
                                推荐位
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-group">
                            <div class="checkbox checkbox-success">
                                <input id="banner" type="checkbox" name="banner" value="1"
                                       @if($game->banner) checked @endif >
                                <label for="banner">
                                    滚动推荐位
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel-footer">
                    <button type="submit" class="btn btn-primary">更新游戏</button>
                </div>
            </div>
        </div>
    </form>
@stop